{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import csv\n",
    "import wfdb\n",
    "import heartpy as hp\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "from scipy.signal import resample, butter, filtfilt\n",
    "from scipy.fft import fft, fftfreq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "def funcBPFilter(ppg_signal, order, f1, f2, fs):\n",
    "    fc = [f1, f2]\n",
    "    b, a = butter(order, fc, btype='bandpass', analog=False, output='ba', fs=fs)\n",
    "    signalBP = filtfilt(b, a, ppg_signal)\n",
    "    return signalBP"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "age_group = {15:1.0,16:1.0,17:1.0,18:1.0,19:1.0,\n",
    "             20:2.0,21:2.0,22:2.0,23:2.0,24:2.0,\n",
    "             25:3.0,26:3.0,27:3.0,28:3.0,29:3.0,\n",
    "             30:4.0,31:4.0,32:4.0,33:4.0,34:4.0,\n",
    "             35:5.0,36:5.0,37:5.0,38:5.0,39:5.0,\n",
    "             40:6.0,41:6.0,42:6.0,43:6.0,44:6.0,\n",
    "             45:7.0,46:7.0,47:7.0,48:7.0,49:7.0,\n",
    "             50:8.0,51:8.0,52:8.0,53:8.0,54:8.0,\n",
    "             55:9.0,56:9.0,57:9.0,58:9.0,59:9.0,\n",
    "             60:10.0,61:10.0,62:10.0,63:10.0,64:10.0,\n",
    "             65:11.0,66:11.0,67:11.0,68:11.0,69:11.0,\n",
    "             70:12.0,71:12.0,72:12.0,73:12.0,74:12.0,\n",
    "             75:13.0,76:13.0,77:13.0,78:13.0,79:13.0,\n",
    "             80:14.0,81:14.0,82:14.0,83:14.0,84:14.0,\n",
    "             85:15.0,86:15.0,87:15.0,88:15.0,89:15.0,\n",
    "             90:16.0,91:16.0,92:16.0,93:16.0,94:16.0,\n",
    "             95:17.0,96:17.0,97:17.0,98:17.0,99:17.0,100:17.0,\n",
    "             }"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "subjects = pd.read_excel(r\"D:\\Proga\\AML\\datasets\\lucilacapurro\\PPG_Signal_Dataset\\subjects_metadata.xlsx\",dtype = {\"ID\":str})\n",
    "#subjects.dropna(inplace=True)\n",
    "subjects = subjects[subjects['observations'].isna()]\n",
    "subjects = subjects.reset_index()\n",
    "subjects = subjects[[\"subjectcode\",\"age\"]]\n",
    "subjects[\"age\"] = subjects[\"age\"].map(age_group)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "ids = subjects[\"subjectcode\"].values\n",
    "age_groups = subjects[\"age\"].values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1097, 'S02', 1.0, 20138551146.930084, 1247535251262.3552, 0.016142671019958994)\n",
      "Process end: S02\n",
      "(1098, 'S03', 1.0, 2635688055.7230253, 60636740478.54042, 0.04346684922247438)\n",
      "Process end: S03\n",
      "(1099, 'S04', 1.0, 1360520839.8534014, 73150761281.25041, 0.01859886098276495)\n",
      "Process end: S04\n",
      "(1100, 'S05', 1.0, 79834451591.88548, 8544315827516.501, 0.009343574512400747)\n",
      "Process end: S05\n",
      "(1101, 'S06', 1.0, 583540418.0884587, 54488359312.84312, 0.010709451072624165)\n",
      "Process end: S06\n",
      "(1102, 'S07', 1.0, 2793710922.2089357, 83650037298.19888, 0.03339760521863017)\n",
      "Process end: S07\n",
      "(1103, 'S08', 1.0, 53249861094.82048, 480758394943.80994, 0.11076220749310933)\n",
      "Process end: S08\n",
      "(1104, 'S09', 1.0, 6827444516.693596, 111313543987.16437, 0.06133525420303636)\n",
      "Process end: S09\n",
      "(1105, 'S10', 1.0, 14428059893.11713, 773790322740.9648, 0.018645955459883786)\n",
      "Process end: S10\n",
      "(1106, 'S11', 1.0, 9083895427.903616, 226009727082.5801, 0.0401924976644236)\n",
      "Process end: S11\n",
      "(1107, 'S12', 2.0, 22774936870.994938, 335900098227.0301, 0.06780270976759788)\n",
      "Process end: S12\n",
      "(1108, 'S13', 2.0, 477112029227.37476, 3576106315450.4434, 0.13341662331626686)\n",
      "Process end: S13\n",
      "(1109, 'S14', 2.0, 5947400157.271835, 208491988367.29092, 0.028525797100628004)\n",
      "Process end: S14\n",
      "(1110, 'S15', 2.0, 11903704841.39323, 871341518536.9028, 0.013661353887257798)\n",
      "Process end: S15\n",
      "(1111, 'S16', 2.0, 9792377008.768509, 149243927944.8898, 0.06561323561776307)\n",
      "Process end: S16\n",
      "(1112, 'S17', 2.0, 8797395115.836079, 149487730036.67157, 0.05885028231867556)\n",
      "Process end: S17\n",
      "(1113, 'S18', 2.0, 3519260871.1410193, 158333518243.46857, 0.022226884807356278)\n",
      "Process end: S18\n",
      "(1114, 'S19', 2.0, 4650153020.054591, 284283809756.1872, 0.01635743176525861)\n",
      "Process end: S19\n",
      "(1115, 'S20', 2.0, 18584421874.19349, 193018668381.4669, 0.09628302811345016)\n",
      "Process end: S20\n",
      "(1116, 'S21', 2.0, 1446662758.535736, 267096190065.52875, 0.005416261303393415)\n",
      "Process end: S21\n",
      "(1117, 'S22', 2.0, 293530965552.109, 2506055948078.3057, 0.11712865619668009)\n",
      "Process end: S22\n",
      "(1118, 'S23', 2.0, 82068491501.7763, 3170226633311.7295, 0.025887263276204546)\n",
      "Process end: S23\n",
      "(1119, 'S24', 2.0, 1128571865.7664077, 264265297464.2857, 0.004270601840633007)\n",
      "Process end: S24\n",
      "(1120, 'S26', 2.0, 13950712319.86522, 579825453166.0526, 0.024060193017897684)\n",
      "Process end: S26\n",
      "(1121, 'S27', 2.0, 107445786674.28003, 2732150623472.246, 0.03932645065436726)\n",
      "Process end: S27\n",
      "(1122, 'S28', 2.0, 1473852100.606315, 392531363595.53015, 0.003754737168276298)\n",
      "Process end: S28\n",
      "(1123, 'S29', 2.0, 4770507281.48139, 328411188064.6998, 0.014526019377091255)\n",
      "Process end: S29\n",
      "(1124, 'S30', 2.0, 37283087171.25217, 947510921011.3478, 0.03934845113073441)\n",
      "Process end: S30\n",
      "(1125, 'S31', 2.0, 13159682353.01356, 347871980067.28326, 0.03782909549216437)\n",
      "Process end: S31\n",
      "(1126, 'S32', 2.0, 19809933295.186172, 776463203472.7811, 0.025513035526455063)\n",
      "Process end: S32\n",
      "(1127, 'S33', 2.0, 36507290139.09044, 1872176276705.1956, 0.01949992134466038)\n",
      "Process end: S33\n",
      "(1128, 'S34', 2.0, 4564057234.058816, 193864934381.4465, 0.02354245881866716)\n",
      "Process end: S34\n",
      "(1129, 'S35', 2.0, 251667149325.75888, 1358189723173.7913, 0.18529601942331592)\n",
      "Process end: S35\n",
      "(1130, 'S36', 3.0, 33676992580.483055, 2449010604922.2905, 0.013751264495464143)\n",
      "Process end: S36\n",
      "(1131, 'S37', 4.0, 13988818608.15636, 95806245199.31262, 0.14601155257733373)\n",
      "Process end: S37\n",
      "(1132, 'S38', 4.0, 16033238840.699747, 1118384187239.8748, 0.014336074332621877)\n",
      "Process end: S38\n",
      "(1133, 'S39', 4.0, 72264440032.05356, 2945440224868.14, 0.024534342751867815)\n",
      "Process end: S39\n",
      "(1134, 'S40', 6.0, 57977310101.285576, 4090037682238.2666, 0.014175250842568664)\n",
      "Process end: S40\n",
      "(1135, 'S41', 6.0, 28510809251.27514, 3955885160913.3877, 0.007207188300858608)\n",
      "Process end: S41\n",
      "(1136, 'S43', 6.0, 420197491979.1237, 1488562890067.6426, 0.2822840034390682)\n",
      "Process end: S43\n",
      "(1137, 'S44', 7.0, 10191065884.970379, 370303453097.10156, 0.02752085026411585)\n",
      "Process end: S44\n",
      "(1138, 'S45', 7.0, 10283031606.11392, 201603662272.3775, 0.051006174640919895)\n",
      "Process end: S45\n",
      "(1139, 'S46', 7.0, 29887134715.272133, 883041883815.814, 0.03384565926377511)\n",
      "Process end: S46\n",
      "(1140, 'S48', 8.0, 28260714310.698116, 781400827113.861, 0.03616673201521981)\n",
      "Process end: S48\n",
      "(1141, 'S49', 8.0, 13447125484.243105, 188158526265.77426, 0.07146700046560216)\n",
      "Process end: S49\n",
      "(1142, 'S50', 8.0, 54731055235.80414, 1564941465695.7158, 0.034973228351050635)\n",
      "Process end: S50\n",
      "(1143, 'S51', 8.0, 26801542309.308434, 1815559777272.524, 0.014762137080152662)\n",
      "Process end: S51\n",
      "(1144, 'S53', 9.0, 43479767465.4136, 229352502352.56586, 0.18957616341405997)\n",
      "Process end: S53\n",
      "(1145, 'S54', 9.0, 57388419190.75506, 6636526020978.609, 0.00864735842357063)\n",
      "Process end: S54\n",
      "(1146, 'S57', 14.0, 137877209183.84506, 1951612181457.8413, 0.07064785232117772)\n",
      "Process end: S57\n",
      "(1147, 'S59', 15.0, 8030867055.50569, 542359947067.9301, 0.014807264251207382)\n",
      "Process end: S59\n"
     ]
    }
   ],
   "source": [
    "result = []\n",
    "result_metadata = []\n",
    "\n",
    "new_id = 1096\n",
    "\n",
    "for id in ids:\n",
    "    new_id += 1 \n",
    "    try:\n",
    "        df_ppg = pd.read_csv(\"D:\\\\Proga\\\\AML\\\\datasets\\\\lucilacapurro\\\\PPG_Signal_Dataset\\\\data\\\\\"+id+\".csv\")\n",
    "        signal_ppg = df_ppg['PPG'].values\n",
    "        #print(record.__dict__)\n",
    "        #print(record.p_signal.shape)\n",
    "        #channel_index = record.sig_name.index('NIBP')\n",
    "        signal = signal_ppg.reshape(-1, 1).astype(np.float32)\n",
    "        fs = 500 \n",
    "        #print(len(signal[0]))\n",
    "        five_minute_samples = 60 * 5 * fs\n",
    "\n",
    "        signal = signal[:five_minute_samples].flatten()\n",
    "\n",
    "        signal = funcBPFilter(signal, order=2, f1=0.5, f2=4.0, fs=fs)\n",
    "        \n",
    "        try:\n",
    "            wd, m = hp.process(signal, fs)\n",
    "            \n",
    "            # Вычисляем частотные характеристики с помощью scipy\n",
    "            n = len(signal)\n",
    "            yf = fft(signal)\n",
    "            xf = fftfreq(n, 1/fs)\n",
    "            \n",
    "            # Определяем границы для LF и HF\n",
    "            lf_band = (0.04, 0.15)\n",
    "            hf_band = (0.15, 0.4)\n",
    "            \n",
    "            # Вычисляем LF и HF\n",
    "            lf_mask = (xf >= lf_band[0]) & (xf <= lf_band[1])\n",
    "            hf_mask = (xf >= hf_band[0]) & (xf <= hf_band[1])\n",
    "            \n",
    "            lf = np.trapz(np.abs(yf[lf_mask])**2, xf[lf_mask])\n",
    "            hf = np.trapz(np.abs(yf[hf_mask])**2, xf[hf_mask])\n",
    "            lf_hf_ratio = lf / hf\n",
    "            \n",
    "            freq_features = {\n",
    "                'lf': lf,\n",
    "                'hf': hf,\n",
    "                'lf_hf_ratio': lf_hf_ratio\n",
    "            }\n",
    "\n",
    "            idx = int(subjects[subjects[\"subjectcode\"] == id].index.to_list()[0])\n",
    "            age_group = age_groups[idx]\n",
    "\n",
    "            result_metadata.append({\n",
    "                'id': new_id,\n",
    "                'age_group': age_group,\n",
    "                'lf': freq_features['lf'],\n",
    "                'hf': freq_features['hf'],\n",
    "                'lf_hf_ratio': freq_features['lf_hf_ratio'],\n",
    "                **m\n",
    "            })\n",
    "\n",
    "            print((new_id, id, age_group, freq_features['lf'], freq_features['hf'], freq_features['lf_hf_ratio']))\n",
    "\n",
    "        except hp.exceptions.BadSignalWarning as e:\n",
    "            result_metadata.append({\n",
    "                'id': new_id,\n",
    "                'age_group': None,\n",
    "                'error': \"BadSignalWarning\"\n",
    "            })\n",
    "            print((new_id, id, None, None, None, \"BadSignalWarning\"))\n",
    "\n",
    "    except FileNotFoundError as e:\n",
    "        result_metadata.append({\n",
    "            'id': new_id,\n",
    "            'age_group': None,\n",
    "            'error': \"FileNotFound\"\n",
    "        })\n",
    "        print((new_id, id, None, None, None, \"FileNotFound\"))\n",
    "\n",
    "    print(f\"Process end: {id}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>age_group</th>\n",
       "      <th>bpm</th>\n",
       "      <th>ibi</th>\n",
       "      <th>sdnn</th>\n",
       "      <th>sdsd</th>\n",
       "      <th>rmssd</th>\n",
       "      <th>pnn20</th>\n",
       "      <th>pnn50</th>\n",
       "      <th>hr_mad</th>\n",
       "      <th>sd1</th>\n",
       "      <th>sd2</th>\n",
       "      <th>s</th>\n",
       "      <th>sd1/sd2</th>\n",
       "      <th>breathingrate</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1097</td>\n",
       "      <td>1.0</td>\n",
       "      <td>66.528681</td>\n",
       "      <td>901.866667</td>\n",
       "      <td>139.237383</td>\n",
       "      <td>99.014087</td>\n",
       "      <td>147.999289</td>\n",
       "      <td>0.815789</td>\n",
       "      <td>0.684211</td>\n",
       "      <td>109.0</td>\n",
       "      <td>104.401951</td>\n",
       "      <td>133.186849</td>\n",
       "      <td>43683.741807</td>\n",
       "      <td>0.783876</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1098</td>\n",
       "      <td>1.0</td>\n",
       "      <td>87.491410</td>\n",
       "      <td>685.781609</td>\n",
       "      <td>51.637758</td>\n",
       "      <td>18.079964</td>\n",
       "      <td>32.259425</td>\n",
       "      <td>0.554913</td>\n",
       "      <td>0.115607</td>\n",
       "      <td>34.0</td>\n",
       "      <td>22.808630</td>\n",
       "      <td>69.406116</td>\n",
       "      <td>4973.324812</td>\n",
       "      <td>0.328626</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1099</td>\n",
       "      <td>1.0</td>\n",
       "      <td>85.733017</td>\n",
       "      <td>699.847059</td>\n",
       "      <td>66.997455</td>\n",
       "      <td>51.641917</td>\n",
       "      <td>61.829504</td>\n",
       "      <td>0.568047</td>\n",
       "      <td>0.130178</td>\n",
       "      <td>32.0</td>\n",
       "      <td>43.718844</td>\n",
       "      <td>84.198819</td>\n",
       "      <td>11564.438156</td>\n",
       "      <td>0.519233</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1100</td>\n",
       "      <td>1.0</td>\n",
       "      <td>85.820597</td>\n",
       "      <td>699.132867</td>\n",
       "      <td>77.386166</td>\n",
       "      <td>76.555248</td>\n",
       "      <td>104.565914</td>\n",
       "      <td>0.765152</td>\n",
       "      <td>0.416667</td>\n",
       "      <td>44.0</td>\n",
       "      <td>73.934174</td>\n",
       "      <td>79.127325</td>\n",
       "      <td>18378.987331</td>\n",
       "      <td>0.934370</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1101</td>\n",
       "      <td>1.0</td>\n",
       "      <td>71.880441</td>\n",
       "      <td>834.719424</td>\n",
       "      <td>68.374343</td>\n",
       "      <td>36.878553</td>\n",
       "      <td>57.545412</td>\n",
       "      <td>0.678832</td>\n",
       "      <td>0.328467</td>\n",
       "      <td>42.0</td>\n",
       "      <td>40.660488</td>\n",
       "      <td>85.246936</td>\n",
       "      <td>10889.332014</td>\n",
       "      <td>0.476973</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1102</td>\n",
       "      <td>1.0</td>\n",
       "      <td>90.274373</td>\n",
       "      <td>664.640449</td>\n",
       "      <td>65.697083</td>\n",
       "      <td>53.676468</td>\n",
       "      <td>64.004971</td>\n",
       "      <td>0.534091</td>\n",
       "      <td>0.130682</td>\n",
       "      <td>38.0</td>\n",
       "      <td>45.258209</td>\n",
       "      <td>81.672066</td>\n",
       "      <td>11612.367872</td>\n",
       "      <td>0.554146</td>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1103</td>\n",
       "      <td>1.0</td>\n",
       "      <td>71.415046</td>\n",
       "      <td>840.159091</td>\n",
       "      <td>125.610951</td>\n",
       "      <td>83.204665</td>\n",
       "      <td>113.880099</td>\n",
       "      <td>0.707692</td>\n",
       "      <td>0.461538</td>\n",
       "      <td>80.0</td>\n",
       "      <td>78.388370</td>\n",
       "      <td>152.423695</td>\n",
       "      <td>37536.518707</td>\n",
       "      <td>0.514279</td>\n",
       "      <td>0.266667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1104</td>\n",
       "      <td>1.0</td>\n",
       "      <td>68.937551</td>\n",
       "      <td>870.352941</td>\n",
       "      <td>93.774725</td>\n",
       "      <td>32.705072</td>\n",
       "      <td>53.477583</td>\n",
       "      <td>0.755556</td>\n",
       "      <td>0.281481</td>\n",
       "      <td>70.0</td>\n",
       "      <td>37.810438</td>\n",
       "      <td>127.450770</td>\n",
       "      <td>15139.238762</td>\n",
       "      <td>0.296667</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1105</td>\n",
       "      <td>1.0</td>\n",
       "      <td>106.761566</td>\n",
       "      <td>562.000000</td>\n",
       "      <td>49.697196</td>\n",
       "      <td>38.460218</td>\n",
       "      <td>46.149766</td>\n",
       "      <td>0.421801</td>\n",
       "      <td>0.099526</td>\n",
       "      <td>28.0</td>\n",
       "      <td>32.630731</td>\n",
       "      <td>62.182855</td>\n",
       "      <td>6374.517617</td>\n",
       "      <td>0.524754</td>\n",
       "      <td>0.100000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>1106</td>\n",
       "      <td>1.0</td>\n",
       "      <td>76.148706</td>\n",
       "      <td>787.931973</td>\n",
       "      <td>62.668294</td>\n",
       "      <td>19.759699</td>\n",
       "      <td>31.467155</td>\n",
       "      <td>0.454545</td>\n",
       "      <td>0.104895</td>\n",
       "      <td>48.0</td>\n",
       "      <td>22.245783</td>\n",
       "      <td>85.039842</td>\n",
       "      <td>5943.195424</td>\n",
       "      <td>0.261592</td>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>1107</td>\n",
       "      <td>2.0</td>\n",
       "      <td>65.022346</td>\n",
       "      <td>922.759690</td>\n",
       "      <td>57.817244</td>\n",
       "      <td>36.202363</td>\n",
       "      <td>52.247309</td>\n",
       "      <td>0.609375</td>\n",
       "      <td>0.242188</td>\n",
       "      <td>32.0</td>\n",
       "      <td>36.939058</td>\n",
       "      <td>72.947206</td>\n",
       "      <td>8465.338925</td>\n",
       "      <td>0.506381</td>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1108</td>\n",
       "      <td>2.0</td>\n",
       "      <td>75.010418</td>\n",
       "      <td>799.888889</td>\n",
       "      <td>98.188531</td>\n",
       "      <td>56.508484</td>\n",
       "      <td>72.321191</td>\n",
       "      <td>0.574468</td>\n",
       "      <td>0.290780</td>\n",
       "      <td>72.0</td>\n",
       "      <td>51.138789</td>\n",
       "      <td>126.229175</td>\n",
       "      <td>20279.631247</td>\n",
       "      <td>0.405127</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>1109</td>\n",
       "      <td>2.0</td>\n",
       "      <td>88.755870</td>\n",
       "      <td>676.011628</td>\n",
       "      <td>79.403151</td>\n",
       "      <td>23.572219</td>\n",
       "      <td>34.455976</td>\n",
       "      <td>0.440476</td>\n",
       "      <td>0.113095</td>\n",
       "      <td>63.0</td>\n",
       "      <td>24.357130</td>\n",
       "      <td>109.975048</td>\n",
       "      <td>8415.310491</td>\n",
       "      <td>0.221479</td>\n",
       "      <td>0.100000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>1110</td>\n",
       "      <td>2.0</td>\n",
       "      <td>90.062112</td>\n",
       "      <td>666.206897</td>\n",
       "      <td>55.066968</td>\n",
       "      <td>26.086577</td>\n",
       "      <td>37.730001</td>\n",
       "      <td>0.511765</td>\n",
       "      <td>0.123529</td>\n",
       "      <td>38.0</td>\n",
       "      <td>26.636615</td>\n",
       "      <td>71.069848</td>\n",
       "      <td>5947.223989</td>\n",
       "      <td>0.374795</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>1111</td>\n",
       "      <td>2.0</td>\n",
       "      <td>80.147110</td>\n",
       "      <td>748.623377</td>\n",
       "      <td>75.511595</td>\n",
       "      <td>28.195493</td>\n",
       "      <td>43.655454</td>\n",
       "      <td>0.563758</td>\n",
       "      <td>0.214765</td>\n",
       "      <td>52.0</td>\n",
       "      <td>30.868891</td>\n",
       "      <td>102.734184</td>\n",
       "      <td>9962.902355</td>\n",
       "      <td>0.300473</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>1112</td>\n",
       "      <td>2.0</td>\n",
       "      <td>90.470131</td>\n",
       "      <td>663.202312</td>\n",
       "      <td>79.476245</td>\n",
       "      <td>51.700898</td>\n",
       "      <td>69.068117</td>\n",
       "      <td>0.660714</td>\n",
       "      <td>0.309524</td>\n",
       "      <td>48.0</td>\n",
       "      <td>48.813698</td>\n",
       "      <td>101.202464</td>\n",
       "      <td>15519.676749</td>\n",
       "      <td>0.482337</td>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>1113</td>\n",
       "      <td>2.0</td>\n",
       "      <td>86.584445</td>\n",
       "      <td>692.965116</td>\n",
       "      <td>65.102950</td>\n",
       "      <td>21.101237</td>\n",
       "      <td>34.106472</td>\n",
       "      <td>0.497076</td>\n",
       "      <td>0.116959</td>\n",
       "      <td>48.0</td>\n",
       "      <td>24.079213</td>\n",
       "      <td>87.334010</td>\n",
       "      <td>6606.562664</td>\n",
       "      <td>0.275714</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>1114</td>\n",
       "      <td>2.0</td>\n",
       "      <td>71.360609</td>\n",
       "      <td>840.800000</td>\n",
       "      <td>66.044088</td>\n",
       "      <td>84.334038</td>\n",
       "      <td>96.274675</td>\n",
       "      <td>0.455285</td>\n",
       "      <td>0.146341</td>\n",
       "      <td>23.0</td>\n",
       "      <td>68.076472</td>\n",
       "      <td>56.223528</td>\n",
       "      <td>12024.443944</td>\n",
       "      <td>1.210818</td>\n",
       "      <td>0.233333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>1115</td>\n",
       "      <td>2.0</td>\n",
       "      <td>73.896578</td>\n",
       "      <td>811.945578</td>\n",
       "      <td>66.239288</td>\n",
       "      <td>24.455907</td>\n",
       "      <td>40.744779</td>\n",
       "      <td>0.595890</td>\n",
       "      <td>0.226027</td>\n",
       "      <td>50.0</td>\n",
       "      <td>28.810777</td>\n",
       "      <td>89.371499</td>\n",
       "      <td>8089.168699</td>\n",
       "      <td>0.322371</td>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>1116</td>\n",
       "      <td>2.0</td>\n",
       "      <td>72.740743</td>\n",
       "      <td>824.847222</td>\n",
       "      <td>77.573471</td>\n",
       "      <td>27.100868</td>\n",
       "      <td>42.989021</td>\n",
       "      <td>0.573427</td>\n",
       "      <td>0.216783</td>\n",
       "      <td>50.0</td>\n",
       "      <td>30.389018</td>\n",
       "      <td>105.128862</td>\n",
       "      <td>10036.643502</td>\n",
       "      <td>0.289064</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>1117</td>\n",
       "      <td>2.0</td>\n",
       "      <td>72.589364</td>\n",
       "      <td>826.567376</td>\n",
       "      <td>91.994550</td>\n",
       "      <td>41.032466</td>\n",
       "      <td>68.666174</td>\n",
       "      <td>0.739130</td>\n",
       "      <td>0.507246</td>\n",
       "      <td>66.0</td>\n",
       "      <td>48.522684</td>\n",
       "      <td>119.899111</td>\n",
       "      <td>18277.241475</td>\n",
       "      <td>0.404696</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>1118</td>\n",
       "      <td>2.0</td>\n",
       "      <td>94.355490</td>\n",
       "      <td>635.893048</td>\n",
       "      <td>26.750367</td>\n",
       "      <td>15.376979</td>\n",
       "      <td>22.668722</td>\n",
       "      <td>0.284946</td>\n",
       "      <td>0.021505</td>\n",
       "      <td>16.0</td>\n",
       "      <td>16.028801</td>\n",
       "      <td>34.170965</td>\n",
       "      <td>1720.711891</td>\n",
       "      <td>0.469077</td>\n",
       "      <td>0.100000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>1119</td>\n",
       "      <td>2.0</td>\n",
       "      <td>77.249318</td>\n",
       "      <td>776.705882</td>\n",
       "      <td>76.712679</td>\n",
       "      <td>46.441768</td>\n",
       "      <td>70.419233</td>\n",
       "      <td>0.756579</td>\n",
       "      <td>0.368421</td>\n",
       "      <td>60.0</td>\n",
       "      <td>49.787637</td>\n",
       "      <td>96.225194</td>\n",
       "      <td>15050.820688</td>\n",
       "      <td>0.517407</td>\n",
       "      <td>0.200000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>1120</td>\n",
       "      <td>2.0</td>\n",
       "      <td>71.985905</td>\n",
       "      <td>833.496503</td>\n",
       "      <td>32.558473</td>\n",
       "      <td>16.903591</td>\n",
       "      <td>29.980275</td>\n",
       "      <td>0.535211</td>\n",
       "      <td>0.091549</td>\n",
       "      <td>18.0</td>\n",
       "      <td>21.198320</td>\n",
       "      <td>40.984250</td>\n",
       "      <td>2729.407095</td>\n",
       "      <td>0.517231</td>\n",
       "      <td>0.366667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>1121</td>\n",
       "      <td>2.0</td>\n",
       "      <td>75.100806</td>\n",
       "      <td>798.926174</td>\n",
       "      <td>79.381679</td>\n",
       "      <td>57.947047</td>\n",
       "      <td>86.285666</td>\n",
       "      <td>0.743243</td>\n",
       "      <td>0.506757</td>\n",
       "      <td>58.0</td>\n",
       "      <td>61.012365</td>\n",
       "      <td>94.551625</td>\n",
       "      <td>18123.277011</td>\n",
       "      <td>0.645281</td>\n",
       "      <td>0.300000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>1122</td>\n",
       "      <td>2.0</td>\n",
       "      <td>78.853527</td>\n",
       "      <td>760.904459</td>\n",
       "      <td>55.136401</td>\n",
       "      <td>26.270179</td>\n",
       "      <td>40.692720</td>\n",
       "      <td>0.583333</td>\n",
       "      <td>0.185897</td>\n",
       "      <td>38.0</td>\n",
       "      <td>28.771579</td>\n",
       "      <td>71.940555</td>\n",
       "      <td>6502.604660</td>\n",
       "      <td>0.399935</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>1123</td>\n",
       "      <td>2.0</td>\n",
       "      <td>85.097098</td>\n",
       "      <td>705.076923</td>\n",
       "      <td>62.421359</td>\n",
       "      <td>24.837157</td>\n",
       "      <td>36.791562</td>\n",
       "      <td>0.428571</td>\n",
       "      <td>0.190476</td>\n",
       "      <td>30.0</td>\n",
       "      <td>26.015541</td>\n",
       "      <td>84.521898</td>\n",
       "      <td>6907.994461</td>\n",
       "      <td>0.307796</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>1124</td>\n",
       "      <td>2.0</td>\n",
       "      <td>64.880779</td>\n",
       "      <td>924.773109</td>\n",
       "      <td>83.013863</td>\n",
       "      <td>59.899046</td>\n",
       "      <td>86.397896</td>\n",
       "      <td>0.771930</td>\n",
       "      <td>0.447368</td>\n",
       "      <td>58.0</td>\n",
       "      <td>61.092084</td>\n",
       "      <td>99.421535</td>\n",
       "      <td>19081.621365</td>\n",
       "      <td>0.614475</td>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>1125</td>\n",
       "      <td>2.0</td>\n",
       "      <td>80.047587</td>\n",
       "      <td>749.554140</td>\n",
       "      <td>76.422759</td>\n",
       "      <td>40.688960</td>\n",
       "      <td>54.013379</td>\n",
       "      <td>0.541935</td>\n",
       "      <td>0.206452</td>\n",
       "      <td>54.0</td>\n",
       "      <td>38.151764</td>\n",
       "      <td>100.540069</td>\n",
       "      <td>12050.461519</td>\n",
       "      <td>0.379468</td>\n",
       "      <td>0.100000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>1126</td>\n",
       "      <td>2.0</td>\n",
       "      <td>91.301182</td>\n",
       "      <td>657.165644</td>\n",
       "      <td>57.740616</td>\n",
       "      <td>42.501904</td>\n",
       "      <td>51.053829</td>\n",
       "      <td>0.428571</td>\n",
       "      <td>0.129870</td>\n",
       "      <td>26.0</td>\n",
       "      <td>36.086883</td>\n",
       "      <td>70.175072</td>\n",
       "      <td>7955.767987</td>\n",
       "      <td>0.514241</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>1127</td>\n",
       "      <td>2.0</td>\n",
       "      <td>74.114147</td>\n",
       "      <td>809.562044</td>\n",
       "      <td>120.284508</td>\n",
       "      <td>110.628731</td>\n",
       "      <td>173.940271</td>\n",
       "      <td>0.849624</td>\n",
       "      <td>0.706767</td>\n",
       "      <td>82.0</td>\n",
       "      <td>122.973294</td>\n",
       "      <td>118.442457</td>\n",
       "      <td>45758.110906</td>\n",
       "      <td>1.038253</td>\n",
       "      <td>0.233333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>1128</td>\n",
       "      <td>2.0</td>\n",
       "      <td>77.464789</td>\n",
       "      <td>774.545455</td>\n",
       "      <td>87.135444</td>\n",
       "      <td>25.477644</td>\n",
       "      <td>42.927207</td>\n",
       "      <td>0.607843</td>\n",
       "      <td>0.274510</td>\n",
       "      <td>54.0</td>\n",
       "      <td>30.348173</td>\n",
       "      <td>119.584803</td>\n",
       "      <td>11401.405960</td>\n",
       "      <td>0.253780</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>1129</td>\n",
       "      <td>2.0</td>\n",
       "      <td>91.815629</td>\n",
       "      <td>653.483516</td>\n",
       "      <td>87.829613</td>\n",
       "      <td>24.884891</td>\n",
       "      <td>39.473048</td>\n",
       "      <td>0.574586</td>\n",
       "      <td>0.154696</td>\n",
       "      <td>54.0</td>\n",
       "      <td>27.904834</td>\n",
       "      <td>120.559275</td>\n",
       "      <td>10568.903831</td>\n",
       "      <td>0.231462</td>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>1130</td>\n",
       "      <td>3.0</td>\n",
       "      <td>93.947818</td>\n",
       "      <td>638.652406</td>\n",
       "      <td>22.267744</td>\n",
       "      <td>16.113699</td>\n",
       "      <td>22.921090</td>\n",
       "      <td>0.268817</td>\n",
       "      <td>0.010753</td>\n",
       "      <td>16.0</td>\n",
       "      <td>16.207201</td>\n",
       "      <td>27.016017</td>\n",
       "      <td>1375.558999</td>\n",
       "      <td>0.599911</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>1131</td>\n",
       "      <td>4.0</td>\n",
       "      <td>85.787818</td>\n",
       "      <td>699.400000</td>\n",
       "      <td>70.221113</td>\n",
       "      <td>23.171289</td>\n",
       "      <td>33.539520</td>\n",
       "      <td>0.408284</td>\n",
       "      <td>0.106509</td>\n",
       "      <td>56.0</td>\n",
       "      <td>23.708153</td>\n",
       "      <td>96.288016</td>\n",
       "      <td>7171.662411</td>\n",
       "      <td>0.246221</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>1132</td>\n",
       "      <td>4.0</td>\n",
       "      <td>74.018692</td>\n",
       "      <td>810.606061</td>\n",
       "      <td>68.821658</td>\n",
       "      <td>57.232480</td>\n",
       "      <td>85.727697</td>\n",
       "      <td>0.761905</td>\n",
       "      <td>0.484127</td>\n",
       "      <td>36.0</td>\n",
       "      <td>60.615933</td>\n",
       "      <td>64.928735</td>\n",
       "      <td>12364.416066</td>\n",
       "      <td>0.933576</td>\n",
       "      <td>0.300000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>1133</td>\n",
       "      <td>4.0</td>\n",
       "      <td>75.921177</td>\n",
       "      <td>790.293333</td>\n",
       "      <td>43.669295</td>\n",
       "      <td>35.418589</td>\n",
       "      <td>52.687759</td>\n",
       "      <td>0.617450</td>\n",
       "      <td>0.261745</td>\n",
       "      <td>27.0</td>\n",
       "      <td>37.255176</td>\n",
       "      <td>49.292884</td>\n",
       "      <td>5769.268001</td>\n",
       "      <td>0.755792</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>1134</td>\n",
       "      <td>6.0</td>\n",
       "      <td>70.164415</td>\n",
       "      <td>855.134328</td>\n",
       "      <td>89.055558</td>\n",
       "      <td>38.299194</td>\n",
       "      <td>51.142668</td>\n",
       "      <td>0.534351</td>\n",
       "      <td>0.190840</td>\n",
       "      <td>64.0</td>\n",
       "      <td>36.158274</td>\n",
       "      <td>120.226174</td>\n",
       "      <td>13657.040322</td>\n",
       "      <td>0.300752</td>\n",
       "      <td>0.300000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>1135</td>\n",
       "      <td>6.0</td>\n",
       "      <td>97.642048</td>\n",
       "      <td>614.489362</td>\n",
       "      <td>67.468944</td>\n",
       "      <td>42.796675</td>\n",
       "      <td>59.001970</td>\n",
       "      <td>0.589189</td>\n",
       "      <td>0.275676</td>\n",
       "      <td>37.0</td>\n",
       "      <td>41.716753</td>\n",
       "      <td>85.517236</td>\n",
       "      <td>11207.636279</td>\n",
       "      <td>0.487817</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>1136</td>\n",
       "      <td>6.0</td>\n",
       "      <td>71.040776</td>\n",
       "      <td>844.585366</td>\n",
       "      <td>109.385492</td>\n",
       "      <td>60.937116</td>\n",
       "      <td>103.746993</td>\n",
       "      <td>0.859649</td>\n",
       "      <td>0.657895</td>\n",
       "      <td>74.0</td>\n",
       "      <td>73.327705</td>\n",
       "      <td>136.001641</td>\n",
       "      <td>31330.123885</td>\n",
       "      <td>0.539168</td>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>1137</td>\n",
       "      <td>7.0</td>\n",
       "      <td>48.965435</td>\n",
       "      <td>1225.354167</td>\n",
       "      <td>73.059619</td>\n",
       "      <td>24.501555</td>\n",
       "      <td>39.836508</td>\n",
       "      <td>0.515789</td>\n",
       "      <td>0.231579</td>\n",
       "      <td>46.0</td>\n",
       "      <td>28.151525</td>\n",
       "      <td>99.498076</td>\n",
       "      <td>8799.671933</td>\n",
       "      <td>0.282935</td>\n",
       "      <td>0.200000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>1138</td>\n",
       "      <td>7.0</td>\n",
       "      <td>70.819141</td>\n",
       "      <td>847.228571</td>\n",
       "      <td>68.708738</td>\n",
       "      <td>42.877485</td>\n",
       "      <td>64.641568</td>\n",
       "      <td>0.712230</td>\n",
       "      <td>0.366906</td>\n",
       "      <td>51.0</td>\n",
       "      <td>45.706095</td>\n",
       "      <td>85.950331</td>\n",
       "      <td>12341.602339</td>\n",
       "      <td>0.531773</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>1139</td>\n",
       "      <td>7.0</td>\n",
       "      <td>64.529139</td>\n",
       "      <td>929.812500</td>\n",
       "      <td>63.317867</td>\n",
       "      <td>55.345824</td>\n",
       "      <td>75.447640</td>\n",
       "      <td>0.669291</td>\n",
       "      <td>0.377953</td>\n",
       "      <td>35.0</td>\n",
       "      <td>53.349371</td>\n",
       "      <td>72.338953</td>\n",
       "      <td>12124.152511</td>\n",
       "      <td>0.737492</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>1140</td>\n",
       "      <td>8.0</td>\n",
       "      <td>78.783179</td>\n",
       "      <td>761.583893</td>\n",
       "      <td>32.774417</td>\n",
       "      <td>17.488681</td>\n",
       "      <td>27.766257</td>\n",
       "      <td>0.391608</td>\n",
       "      <td>0.076923</td>\n",
       "      <td>18.0</td>\n",
       "      <td>19.633071</td>\n",
       "      <td>41.804645</td>\n",
       "      <td>2578.473374</td>\n",
       "      <td>0.469639</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>1141</td>\n",
       "      <td>8.0</td>\n",
       "      <td>87.580155</td>\n",
       "      <td>685.086705</td>\n",
       "      <td>34.841648</td>\n",
       "      <td>30.222351</td>\n",
       "      <td>42.633102</td>\n",
       "      <td>0.453488</td>\n",
       "      <td>0.215116</td>\n",
       "      <td>16.0</td>\n",
       "      <td>30.145707</td>\n",
       "      <td>39.089585</td>\n",
       "      <td>3701.999962</td>\n",
       "      <td>0.771195</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>1142</td>\n",
       "      <td>8.0</td>\n",
       "      <td>72.207131</td>\n",
       "      <td>830.942857</td>\n",
       "      <td>49.302821</td>\n",
       "      <td>39.086562</td>\n",
       "      <td>53.771029</td>\n",
       "      <td>0.610294</td>\n",
       "      <td>0.191176</td>\n",
       "      <td>30.0</td>\n",
       "      <td>38.004961</td>\n",
       "      <td>56.200925</td>\n",
       "      <td>6710.171641</td>\n",
       "      <td>0.676234</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>1143</td>\n",
       "      <td>8.0</td>\n",
       "      <td>52.924329</td>\n",
       "      <td>1133.694118</td>\n",
       "      <td>45.277192</td>\n",
       "      <td>35.543909</td>\n",
       "      <td>49.491109</td>\n",
       "      <td>0.602740</td>\n",
       "      <td>0.205479</td>\n",
       "      <td>26.0</td>\n",
       "      <td>34.929369</td>\n",
       "      <td>49.176258</td>\n",
       "      <td>5396.300053</td>\n",
       "      <td>0.710289</td>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>1144</td>\n",
       "      <td>9.0</td>\n",
       "      <td>72.066926</td>\n",
       "      <td>832.559441</td>\n",
       "      <td>20.293518</td>\n",
       "      <td>8.170520</td>\n",
       "      <td>12.957134</td>\n",
       "      <td>0.091549</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>12.0</td>\n",
       "      <td>9.160692</td>\n",
       "      <td>26.925165</td>\n",
       "      <td>774.883658</td>\n",
       "      <td>0.340228</td>\n",
       "      <td>0.233333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>1145</td>\n",
       "      <td>9.0</td>\n",
       "      <td>75.211532</td>\n",
       "      <td>797.750000</td>\n",
       "      <td>44.318842</td>\n",
       "      <td>33.091125</td>\n",
       "      <td>36.423436</td>\n",
       "      <td>0.156028</td>\n",
       "      <td>0.056738</td>\n",
       "      <td>25.0</td>\n",
       "      <td>25.725695</td>\n",
       "      <td>56.355162</td>\n",
       "      <td>4554.604660</td>\n",
       "      <td>0.456492</td>\n",
       "      <td>0.133333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>1146</td>\n",
       "      <td>14.0</td>\n",
       "      <td>70.648791</td>\n",
       "      <td>849.271429</td>\n",
       "      <td>51.184937</td>\n",
       "      <td>38.534319</td>\n",
       "      <td>46.801586</td>\n",
       "      <td>0.345324</td>\n",
       "      <td>0.136691</td>\n",
       "      <td>27.0</td>\n",
       "      <td>33.082682</td>\n",
       "      <td>63.808442</td>\n",
       "      <td>6631.758769</td>\n",
       "      <td>0.518469</td>\n",
       "      <td>0.300000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>1147</td>\n",
       "      <td>15.0</td>\n",
       "      <td>79.182156</td>\n",
       "      <td>757.746479</td>\n",
       "      <td>122.174629</td>\n",
       "      <td>71.294651</td>\n",
       "      <td>96.165408</td>\n",
       "      <td>0.785714</td>\n",
       "      <td>0.392857</td>\n",
       "      <td>60.0</td>\n",
       "      <td>67.622597</td>\n",
       "      <td>150.136347</td>\n",
       "      <td>31895.364333</td>\n",
       "      <td>0.450408</td>\n",
       "      <td>0.266667</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      id  age_group         bpm          ibi        sdnn        sdsd  \\\n",
       "0   1097        1.0   66.528681   901.866667  139.237383   99.014087   \n",
       "1   1098        1.0   87.491410   685.781609   51.637758   18.079964   \n",
       "2   1099        1.0   85.733017   699.847059   66.997455   51.641917   \n",
       "3   1100        1.0   85.820597   699.132867   77.386166   76.555248   \n",
       "4   1101        1.0   71.880441   834.719424   68.374343   36.878553   \n",
       "5   1102        1.0   90.274373   664.640449   65.697083   53.676468   \n",
       "6   1103        1.0   71.415046   840.159091  125.610951   83.204665   \n",
       "7   1104        1.0   68.937551   870.352941   93.774725   32.705072   \n",
       "8   1105        1.0  106.761566   562.000000   49.697196   38.460218   \n",
       "9   1106        1.0   76.148706   787.931973   62.668294   19.759699   \n",
       "10  1107        2.0   65.022346   922.759690   57.817244   36.202363   \n",
       "11  1108        2.0   75.010418   799.888889   98.188531   56.508484   \n",
       "12  1109        2.0   88.755870   676.011628   79.403151   23.572219   \n",
       "13  1110        2.0   90.062112   666.206897   55.066968   26.086577   \n",
       "14  1111        2.0   80.147110   748.623377   75.511595   28.195493   \n",
       "15  1112        2.0   90.470131   663.202312   79.476245   51.700898   \n",
       "16  1113        2.0   86.584445   692.965116   65.102950   21.101237   \n",
       "17  1114        2.0   71.360609   840.800000   66.044088   84.334038   \n",
       "18  1115        2.0   73.896578   811.945578   66.239288   24.455907   \n",
       "19  1116        2.0   72.740743   824.847222   77.573471   27.100868   \n",
       "20  1117        2.0   72.589364   826.567376   91.994550   41.032466   \n",
       "21  1118        2.0   94.355490   635.893048   26.750367   15.376979   \n",
       "22  1119        2.0   77.249318   776.705882   76.712679   46.441768   \n",
       "23  1120        2.0   71.985905   833.496503   32.558473   16.903591   \n",
       "24  1121        2.0   75.100806   798.926174   79.381679   57.947047   \n",
       "25  1122        2.0   78.853527   760.904459   55.136401   26.270179   \n",
       "26  1123        2.0   85.097098   705.076923   62.421359   24.837157   \n",
       "27  1124        2.0   64.880779   924.773109   83.013863   59.899046   \n",
       "28  1125        2.0   80.047587   749.554140   76.422759   40.688960   \n",
       "29  1126        2.0   91.301182   657.165644   57.740616   42.501904   \n",
       "30  1127        2.0   74.114147   809.562044  120.284508  110.628731   \n",
       "31  1128        2.0   77.464789   774.545455   87.135444   25.477644   \n",
       "32  1129        2.0   91.815629   653.483516   87.829613   24.884891   \n",
       "33  1130        3.0   93.947818   638.652406   22.267744   16.113699   \n",
       "34  1131        4.0   85.787818   699.400000   70.221113   23.171289   \n",
       "35  1132        4.0   74.018692   810.606061   68.821658   57.232480   \n",
       "36  1133        4.0   75.921177   790.293333   43.669295   35.418589   \n",
       "37  1134        6.0   70.164415   855.134328   89.055558   38.299194   \n",
       "38  1135        6.0   97.642048   614.489362   67.468944   42.796675   \n",
       "39  1136        6.0   71.040776   844.585366  109.385492   60.937116   \n",
       "40  1137        7.0   48.965435  1225.354167   73.059619   24.501555   \n",
       "41  1138        7.0   70.819141   847.228571   68.708738   42.877485   \n",
       "42  1139        7.0   64.529139   929.812500   63.317867   55.345824   \n",
       "43  1140        8.0   78.783179   761.583893   32.774417   17.488681   \n",
       "44  1141        8.0   87.580155   685.086705   34.841648   30.222351   \n",
       "45  1142        8.0   72.207131   830.942857   49.302821   39.086562   \n",
       "46  1143        8.0   52.924329  1133.694118   45.277192   35.543909   \n",
       "47  1144        9.0   72.066926   832.559441   20.293518    8.170520   \n",
       "48  1145        9.0   75.211532   797.750000   44.318842   33.091125   \n",
       "49  1146       14.0   70.648791   849.271429   51.184937   38.534319   \n",
       "50  1147       15.0   79.182156   757.746479  122.174629   71.294651   \n",
       "\n",
       "         rmssd     pnn20     pnn50  hr_mad         sd1         sd2  \\\n",
       "0   147.999289  0.815789  0.684211   109.0  104.401951  133.186849   \n",
       "1    32.259425  0.554913  0.115607    34.0   22.808630   69.406116   \n",
       "2    61.829504  0.568047  0.130178    32.0   43.718844   84.198819   \n",
       "3   104.565914  0.765152  0.416667    44.0   73.934174   79.127325   \n",
       "4    57.545412  0.678832  0.328467    42.0   40.660488   85.246936   \n",
       "5    64.004971  0.534091  0.130682    38.0   45.258209   81.672066   \n",
       "6   113.880099  0.707692  0.461538    80.0   78.388370  152.423695   \n",
       "7    53.477583  0.755556  0.281481    70.0   37.810438  127.450770   \n",
       "8    46.149766  0.421801  0.099526    28.0   32.630731   62.182855   \n",
       "9    31.467155  0.454545  0.104895    48.0   22.245783   85.039842   \n",
       "10   52.247309  0.609375  0.242188    32.0   36.939058   72.947206   \n",
       "11   72.321191  0.574468  0.290780    72.0   51.138789  126.229175   \n",
       "12   34.455976  0.440476  0.113095    63.0   24.357130  109.975048   \n",
       "13   37.730001  0.511765  0.123529    38.0   26.636615   71.069848   \n",
       "14   43.655454  0.563758  0.214765    52.0   30.868891  102.734184   \n",
       "15   69.068117  0.660714  0.309524    48.0   48.813698  101.202464   \n",
       "16   34.106472  0.497076  0.116959    48.0   24.079213   87.334010   \n",
       "17   96.274675  0.455285  0.146341    23.0   68.076472   56.223528   \n",
       "18   40.744779  0.595890  0.226027    50.0   28.810777   89.371499   \n",
       "19   42.989021  0.573427  0.216783    50.0   30.389018  105.128862   \n",
       "20   68.666174  0.739130  0.507246    66.0   48.522684  119.899111   \n",
       "21   22.668722  0.284946  0.021505    16.0   16.028801   34.170965   \n",
       "22   70.419233  0.756579  0.368421    60.0   49.787637   96.225194   \n",
       "23   29.980275  0.535211  0.091549    18.0   21.198320   40.984250   \n",
       "24   86.285666  0.743243  0.506757    58.0   61.012365   94.551625   \n",
       "25   40.692720  0.583333  0.185897    38.0   28.771579   71.940555   \n",
       "26   36.791562  0.428571  0.190476    30.0   26.015541   84.521898   \n",
       "27   86.397896  0.771930  0.447368    58.0   61.092084   99.421535   \n",
       "28   54.013379  0.541935  0.206452    54.0   38.151764  100.540069   \n",
       "29   51.053829  0.428571  0.129870    26.0   36.086883   70.175072   \n",
       "30  173.940271  0.849624  0.706767    82.0  122.973294  118.442457   \n",
       "31   42.927207  0.607843  0.274510    54.0   30.348173  119.584803   \n",
       "32   39.473048  0.574586  0.154696    54.0   27.904834  120.559275   \n",
       "33   22.921090  0.268817  0.010753    16.0   16.207201   27.016017   \n",
       "34   33.539520  0.408284  0.106509    56.0   23.708153   96.288016   \n",
       "35   85.727697  0.761905  0.484127    36.0   60.615933   64.928735   \n",
       "36   52.687759  0.617450  0.261745    27.0   37.255176   49.292884   \n",
       "37   51.142668  0.534351  0.190840    64.0   36.158274  120.226174   \n",
       "38   59.001970  0.589189  0.275676    37.0   41.716753   85.517236   \n",
       "39  103.746993  0.859649  0.657895    74.0   73.327705  136.001641   \n",
       "40   39.836508  0.515789  0.231579    46.0   28.151525   99.498076   \n",
       "41   64.641568  0.712230  0.366906    51.0   45.706095   85.950331   \n",
       "42   75.447640  0.669291  0.377953    35.0   53.349371   72.338953   \n",
       "43   27.766257  0.391608  0.076923    18.0   19.633071   41.804645   \n",
       "44   42.633102  0.453488  0.215116    16.0   30.145707   39.089585   \n",
       "45   53.771029  0.610294  0.191176    30.0   38.004961   56.200925   \n",
       "46   49.491109  0.602740  0.205479    26.0   34.929369   49.176258   \n",
       "47   12.957134  0.091549  0.000000    12.0    9.160692   26.925165   \n",
       "48   36.423436  0.156028  0.056738    25.0   25.725695   56.355162   \n",
       "49   46.801586  0.345324  0.136691    27.0   33.082682   63.808442   \n",
       "50   96.165408  0.785714  0.392857    60.0   67.622597  150.136347   \n",
       "\n",
       "               s   sd1/sd2  breathingrate  \n",
       "0   43683.741807  0.783876       0.133333  \n",
       "1    4973.324812  0.328626       0.133333  \n",
       "2   11564.438156  0.519233       0.133333  \n",
       "3   18378.987331  0.934370       0.133333  \n",
       "4   10889.332014  0.476973       0.133333  \n",
       "5   11612.367872  0.554146       0.166667  \n",
       "6   37536.518707  0.514279       0.266667  \n",
       "7   15139.238762  0.296667       0.133333  \n",
       "8    6374.517617  0.524754       0.100000  \n",
       "9    5943.195424  0.261592       0.166667  \n",
       "10   8465.338925  0.506381       0.166667  \n",
       "11  20279.631247  0.405127       0.133333  \n",
       "12   8415.310491  0.221479       0.100000  \n",
       "13   5947.223989  0.374795       0.133333  \n",
       "14   9962.902355  0.300473       0.133333  \n",
       "15  15519.676749  0.482337       0.166667  \n",
       "16   6606.562664  0.275714       0.133333  \n",
       "17  12024.443944  1.210818       0.233333  \n",
       "18   8089.168699  0.322371       0.166667  \n",
       "19  10036.643502  0.289064       0.133333  \n",
       "20  18277.241475  0.404696       0.133333  \n",
       "21   1720.711891  0.469077       0.100000  \n",
       "22  15050.820688  0.517407       0.200000  \n",
       "23   2729.407095  0.517231       0.366667  \n",
       "24  18123.277011  0.645281       0.300000  \n",
       "25   6502.604660  0.399935       0.133333  \n",
       "26   6907.994461  0.307796       0.133333  \n",
       "27  19081.621365  0.614475       0.166667  \n",
       "28  12050.461519  0.379468       0.100000  \n",
       "29   7955.767987  0.514241       0.133333  \n",
       "30  45758.110906  1.038253       0.233333  \n",
       "31  11401.405960  0.253780       0.133333  \n",
       "32  10568.903831  0.231462       0.166667  \n",
       "33   1375.558999  0.599911       0.133333  \n",
       "34   7171.662411  0.246221       0.133333  \n",
       "35  12364.416066  0.933576       0.300000  \n",
       "36   5769.268001  0.755792       0.133333  \n",
       "37  13657.040322  0.300752       0.300000  \n",
       "38  11207.636279  0.487817       0.133333  \n",
       "39  31330.123885  0.539168       0.166667  \n",
       "40   8799.671933  0.282935       0.200000  \n",
       "41  12341.602339  0.531773       0.133333  \n",
       "42  12124.152511  0.737492       0.133333  \n",
       "43   2578.473374  0.469639       0.133333  \n",
       "44   3701.999962  0.771195       0.000000  \n",
       "45   6710.171641  0.676234       0.133333  \n",
       "46   5396.300053  0.710289       0.166667  \n",
       "47    774.883658  0.340228       0.233333  \n",
       "48   4554.604660  0.456492       0.133333  \n",
       "49   6631.758769  0.518469       0.300000  \n",
       "50  31895.364333  0.450408       0.266667  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_metadata = pd.DataFrame(result_metadata)\n",
    "df_metadata.dropna(inplace=True)\n",
    "df_metadata"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_metadata.to_csv(r\"D:\\Proga\\AML\\PPG_dataset\\dataset.csv\",mode=\"a\",index=False,header=False)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
